//
//  SortCollectionReusableView.m
//  14__半塘练习
//
//  Created by 冀永金 on 16/8/2.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "SortCollectionReusableView.h"

@interface SortCollectionReusableView ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collection;
@property (nonatomic, strong) UILabel *label;
@end

@implementation SortCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 50)];
        [self addSubview:label];
        label.text = @"分类";
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        layout.itemSize = CGSizeMake((self.frame.size.width - 30) / 2, (self.frame.size.width - 30) / 4);
        //layout.minimumInteritemSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumLineSpacing = 10;
        layout.minimumInteritemSpacing = 5;
        layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        _collection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 50, self.frame.size.width, self.frame.size.height - 50) collectionViewLayout:layout];
        [self addSubview:_collection];
        _collection.delegate = self;
        _collection.dataSource = self;
        [_collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"pool"];
        _collection.backgroundColor = [UIColor whiteColor];
        _collection.pagingEnabled = YES;
    }
    return self;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 11;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"pool" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    return cell;
}

@end
